using Ardalis.Specification;

namespace BuildingBlocks.Domain;

public interface IRepository<TEntity, TKey>
    where TEntity : Entity<TKey>, IAggregateRoot
{
    IQueryable<TEntity> GetQueryableSet();
    IQueryable<TEntity> ApplySpecification(ISpecification<TEntity> specification);
    Task AddOrUpdateAsync(TEntity entity, CancellationToken cancellationToken = default);
    Task AddAsync(TEntity entity, CancellationToken cancellationToken = default);
    Task UpdateAsync(TEntity entity);
    Task DeleteAsync(TEntity entity);
    Task<T?> FirstOrDefaultAsync<T>(IQueryable<T> query);
    Task<T?> SingleOrDefaultAsync<T>(IQueryable<T> query);
    Task<List<T>> ToListAsync<T>(IQueryable<T> query);
}
